/*
 * All rights Reserved, Designed By DataDriver
 * Copyright:    DataDriver.Inc
 * Company:      Zhuo Wo Infomation Technology (ShangHai) CO.LTD
 */
package com.sun.config;

import com.sun.bean.*;
import org.springframework.context.annotation.*;

@Configuration
@ComponentScan("com.sun")
public class BeanConfig {

    @Bean
    public User user() {
        return new User("1", "张三", "上海");
    }

    /**
     * 单例模式时系统初始化时就会创建该对象
     * 多例模式时不会立即创建该对象，只会在调用时创建该对象
     * @return
     */
    @Bean("myInitUser")
    //默认是单例singleton
    @Scope("prototype")
    public InitUser initUser() {
        return new InitUser();
    }


    @Bean(value = "initUser", initMethod = "init", destroyMethod = "destory")
    //懒加载
    @Lazy
    public InitUser2 initUser2() {
        return new InitUser2();
    }

    @Bean
    public InitUser3 initUser3() {
        return new InitUser3();
    }

    @Bean
    public InitUser4 initUser4() {
        return new InitUser4();
    }
}
